package com.baosu.Exception;

import com.baosu.domain.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@ControllerAdvice(annotations = {Controller.class, RestController.class})
@ResponseBody
public class GlobaException {

    @ExceptionHandler(BusinessException.class)
    public Result BusinessExceptionHandler(BusinessException e){
        return Result
                .fail(null)
                .message(e.getMessage())
                .status(e.getStatus());

    }


    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e){
        return Result
                .fail(null)
                .message("系统繁忙，请稍后重试")
                .status(false);
    }
}
